
* import and clean websuse data 

insheet using OrigData/WebUsageData/webuse_050712.csv, clear

rename acct account_number
rename openedcampaignemail NEmailOpen
rename v5 NEmailSent
destring account_number, force replace
drop if account_number ==. | account_number <100000

gen date = date(receivedcampaignemail, "MY")
drop receivedcampaignemail
format date %td
sort account_number date

* remove duplicate dates (checked in KissMetrics - duplicate dates are duplicates not additional emails)
collapse (max) NEmailSent NEmailOpen, by(id account_number date)

* transform date variable to month, year format to merge with other webuse. 
gen month = month(date)
gen year=year(date)
replace date = ym(year,month)
format date %tm

order id account_number date NEmailOpen NEmailSent 

save Data/webuse_050713.dta, replace
